<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
            <%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/common1.js"></script>
<title>Insert title here</title>
</head>
<body>
<div style="margin-left:100px;margin-top:50px;">
<form class="form-horizontal" role="form" action="addumoney.do" method="post">
  <div class="form-group has-warning" >
    <label class="col-sm-2 control-label">提示：</label>
    <div class="col-sm-10">
      <p class="form-control-static">请输入金额</p>
    </div>
  </div>
  <div class="form-group has-warning">
    <label for="inputPassword" class="col-sm-2 control-label">金额：</label>
    <div class="col-lg-2">
      <input type="text" class="form-control" id="money" placeholder="金额">
    </div>
    <button type="button" class="btn btn-default" data-toggle="modal" data-target="#myModal">提交</button>
  </div>
  
  <!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">提示信息：</h4>
      </div>
      <div class="modal-body">
                 你确定要提交吗？
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="addUmoney()" data-toggle="modal" data-target="#myModal1">提交</button>
      </div>
    </div>
  </div>
</div>
<!-- 结果模态框 -->

<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">提示信息：</h4>
      </div>
      
      <div class="modal-body" v-if="money>=0">
                 充值成功!当前余额：{{money}}
      </div>
      <div class="modal-body" v-if="money<0">
                 充值失败！
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>

</form>
</div>
</body>
<script type="text/javascript">
var vue=new Vue({
	el:'#myModal1',
	data:{
		money:-1,
		}
});
function addUmoney(){
	var money=$("#money").val();
	$.ajax({
		url:'addumoney.do',
		data:{umoney:money},
		type:'post',
		dataType:'json',
		success:function(result){
			console.log(result);
			vue.money=result;
		}
	});
}
</script>
</html>